package com.cloud.mall.test.service;

import com.cloud.mall.test.mapper.AccountTblMapper;
import io.seata.core.context.RootContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: 梁二东
 * @Date: 2024/12/16 11:00
 * @Description:
 **/
@Service
@Slf4j
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountTblMapper accountTblMapper;

    @Override
    public void debit(String userId, int money) {
        String xid = RootContext.getXID();
        log.info("开始扣除用户金额，全局事务xid：【{}】", xid);
        accountTblMapper.debit(userId, money);
        log.info("完成扣除用户金额，全局事务xid：【{}】", xid);
    }
}
